import {View, ScrollView, Text, Image, Button} from '@tarojs/components';
import Taro from '@tarojs/taro';
import React from 'react';
import {connect} from 'react-redux';
import * as T from './types';
import './index.less';
import actions from './actions';
import {store2Props} from './selectors';
import 'taro-ui/dist/style/components/tabs.scss';

//@ts-ignore
actions().actions.loadReducer();
//@ts-ignore
@connect<Partial<T.IProps>, any>(store2Props, actions)
export default class packageINewActivityDetail extends React.Component<Partial<T.IProps>, any> {
  constructor(props) {
    super(props);
    this.state = {
      refresherTriggered: false,
    };
  }

  componentDidMount() {}

  componentWillUnmount() {
    this.props.actions.clean();
  }

  componentWillMount(): void {
    this.props.actions.init();
  }

  componentDidShow() {}

  _onScrollToLower = () => {
    console.log('加载====');
    // let {
    //   main: { pageNum, totalPages },
    //   actions: { action },
    // } = this.props;
    // let num = pageNum + 1;
    // if (pageNum == totalPages) return;
    // this.props.actions.action.commonChange('main.pageNum', num);
    // this.props.actions.action.getPosts();
  };

  _onRefresherRefresh = () => {
    let {refresherTriggered} = this.state;
    if (refresherTriggered) return;
    this.setState({
      refresherTriggered: true,
    });
    console.log('刷新====');
    // this.props.actions.action.commonChange('main.pageNum', 1);
    // this.props.actions.action.getPosts();
    setTimeout(() => {
      this.setState({
        refresherTriggered: false,
      });
    }, 2000);
  };

  render() {
    let {refresherTriggered} = this.state;
    return (
      <View className="packageINewActivityDetail">
        <ScrollView
          className="scroll-view"
          scrollY
          onScrollToLower={this._onScrollToLower}
          refresherEnabled
          refresherTriggered={refresherTriggered}
          onRefresherPulling={this._onRefresherRefresh}
        >
          <View className="list">
            <View className="item">
              <Image
                className="item-img"
                mode="aspectFill"
                src="https://ruizhi-ipland.oss-cn-nanjing.aliyuncs.com/newActivity/test.png"
              />
              <View className="item-textBox">
                <Text className="item-textBox-title">
                  这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题
                </Text>
                <View className="item-textBox-memberPrice flex">
                  <Text className="item-textBox-memberPrice-left">会员价</Text>
                  <Text className="item-textBox-memberPrice-right">109.99</Text>
                </View>
                <View className="item-textBox-nonMember flex">
                  <Text className="item-textBox-nonMember-leftText">非会员价 199.99</Text>
                  {/* <View className='item-textBox-nonMember-left flex'>
                    <Text className='item-textBox-nonMember-left-text'>非会员价</Text>
                    <Text className='item-textBox-nonMember-left-num'>199.99</Text>
                  </View> */}
                  <Image
                    className="item-textBox-nonMember-rightIcon"
                    src="https://ruizhi-ipland.oss-cn-nanjing.aliyuncs.com/newActivity/detail/car.png"
                    mode="widthFix"
                    onClick={() => {
                      Taro.showToast({
                        title: '去添加=-=购物车',
                      });
                    }}
                  />
                </View>
              </View>
            </View>
            <View className="item">
              <Image
                className="item-img"
                mode="aspectFill"
                src="https://ruizhi-ipland.oss-cn-nanjing.aliyuncs.com/newActivity/test.png"
              />
              <View className="item-textBox">
                <Text className="item-textBox-title">
                  这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题
                </Text>
                <View className="item-textBox-memberPrice flex">
                  <Text className="item-textBox-memberPrice-left">会员价</Text>
                  <Text className="item-textBox-memberPrice-right">109.99</Text>
                </View>
                <View className="item-textBox-nonMember flex">
                  <Text className="item-textBox-nonMember-leftText">非会员价 199.99</Text>
                  {/* <View className='item-textBox-nonMember-left flex'>
                    <Text className='item-textBox-nonMember-left-text'>非会员价</Text>
                    <Text className='item-textBox-nonMember-left-num'>199.99</Text>
                  </View> */}
                  <Image
                    className="item-textBox-nonMember-rightIcon"
                    src="https://ruizhi-ipland.oss-cn-nanjing.aliyuncs.com/newActivity/detail/car.png"
                    mode="widthFix"
                  />
                </View>
              </View>
            </View>
            <View className="item">
              <Image
                className="item-img"
                mode="aspectFill"
                src="https://ruizhi-ipland.oss-cn-nanjing.aliyuncs.com/newActivity/test.png"
              />
              <View className="item-textBox">
                <Text className="item-textBox-title">
                  这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题这是一个活动标题
                </Text>
                <View className="item-textBox-memberPrice flex">
                  <Text className="item-textBox-memberPrice-left">会员价</Text>
                  <Text className="item-textBox-memberPrice-right">109.99</Text>
                </View>
                <View className="item-textBox-nonMember flex">
                  <Text className="item-textBox-nonMember-leftText">非会员价 199.99</Text>
                  {/* <View className='item-textBox-nonMember-left flex'>
                    <Text className='item-textBox-nonMember-left-text'>非会员价</Text>
                    <Text className='item-textBox-nonMember-left-num'>199.99</Text>
                  </View> */}
                  <Image
                    className="item-textBox-nonMember-rightIcon"
                    src="https://ruizhi-ipland.oss-cn-nanjing.aliyuncs.com/newActivity/detail/car.png"
                    mode="widthFix"
                  />
                </View>
              </View>
            </View>
          </View>
        </ScrollView>
      </View>
    );
  }
}

//create by moon https://github.com/creasy2010/moon
